<script setup lang="ts">
import { useUserStoreWithOut } from '@/store/modules/user'
import { onMounted } from 'vue'
import { ElLoading } from 'element-plus'

import { useRouter } from 'vue-router'

const { replace } = useRouter()

const appStore = useUserStoreWithOut()

const load = async () => {
  const loadCon = ElLoading.service({
    lock: true,
    text: '加载中，请稍后....',
    background: 'rgba(0, 0, 0, 0.7)'
  })
  if (await appStore.checkState()) {
    replace({ name: 'HomeIndex' })
  } else {
    appStore.logout()
  }
  loadCon.close()
}
onMounted(load)
</script>

<template>
  <p>加载中....</p>
</template>
